<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>JS 简洁颜色选取器插件</title>

  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .picker {
      width: 150px;
      margin: 0 auto;
    }

    #color-picker {
      width: 150px;
      height: 20px;
      cursor: pointer;
    }
  </style>
</head>
<body>

<div class="picker">
  <h3>点击下方选择颜色</h3>
  <div id="color-picker"></div>
</div>

<script src="colorpicker.js"></script>

<script type="text/javascript">
  Colorpicker.create({
    el: "color-picker",
    color: "#ff0000",
    change: function (elem, hex) {
      elem.style.backgroundColor = hex;
    }
  })
</script>
</body>
</html>
